\subsection{Motivation}
\begin{frame}
  \frametitle{Introduction: Motivation}
\textsf{Test-Case Generation for SQL Nested Queries with Existential Conditions\\}

\begin{description}
  \item[Objective] Test database queries
  \item[Approach] Obtain small database instances such that executing the query on them produces a non empty result
\end{description}
\pause
\begin{center}
\begin{tabular}{l c c c}
\\
  \cod{select C from T where A + B = C;} & $\Rightarrow$ & 
  \begin{tabular}{|c|c|c|}
    \hline    \multicolumn{3}{|c|}{\textbf{T}} \\
    \hline
    A & B & C \\
    \hline
    1 & 2 & 3\\
    \hline
  \end{tabular} & \\
\end{tabular}
\end{center}
\end{frame}

%\begin{frame}
 % \frametitle{Introduction: Motivation}
 % Nested SQL existential subqueries
 % \begin{itemize}
 % \item Widely used in databases
 % \item Necessary for some SQL queries
 % \item Other subqueries can be translated into existential subqueries
    % cuales
 % \end{itemize}
%\end{frame}

\subsection{Approach}
\begin{frame}
  \frametitle{Introduction: Approach}
  To obtain this database instances we use:
  \begin{itemize}
  \item Constraint programming
  \item Over symbolic database instances\\
\pause

\cod{ \ \\select C from T where A + B = C;}\\

{\small
\begin{tabular}{c c c}
\\
\textbf{Symbolic Database} & \textbf{Constraints} & \textbf{Test Case} \\
    \begin{tabular}{|c|c|c|}

    \hline    \multicolumn{3}{|c|}{\textbf{Symbolic Table T}} \\
    \hline
    \textbf{A} & \textbf{B} & \textbf{C} \\
    \hline
    $T.A_0$ & $T.B_0$ & $T.C_0$\\
    $T.A_1$ & $T.B_1$ & $T.C_1$\\
    \hline
  \end{tabular}& \pause \begin{tabular}{c}($T.A_0$ + $T.B_0$) = $T.C_0$\pause \ or \\ ($T.A_1$ + $T.B_1$) = $T.C_1$\end{tabular}
 & \pause
    \begin{tabular}{|c|c|c|}

    \hline    \multicolumn{3}{|c|}{\textbf{T}} \\
    \hline
    \textbf{A} & \textbf{B} & \textbf{C} \\
    \hline
    1 & 2 & 3\\
    1 & 1 & -9\\
    \hline 
\end{tabular}
\end{tabular}
}\\

%Constraint the values of a symbolic database instance is like executing the query on it.\\

    \begin{block}{SQL Positive Test Case}
      Database instances such that the query/relation studied produces a non-empty result
    \end{block}


  \end{itemize}
\end{frame}
\subsection{Scope}
\begin{frame}{Introduction: Scope}
\begin{description}
\item[Tables] {\small\cod{create table T ($A_1$ $Type(A_1)$, \dots, $A_n$ $Type(A_n)$, $C_1$ , \dots, $C_m$)}}\\
With: 
\begin{description}
\item [$A_1$,\dots, $A_n$] Attribute names
\item [$C_1$ , \dots, $C_m$] primary or foreign key constraints
\end{description}
\end{description}
\end{frame}
\begin{frame}
\frametitle{Introduction: Scope}
\begin{description}[style=nextline]
\item[View] \cod{create view V($A_1$, \dots, $A_n$) as \  $Q$} % Q query, A_1 ... A_n atribute names

With Q a query, either a basic query, an union or intersection of queries.
\item[Basic Query] \cod{ Q = select $e_1$, \dots, $e_n$ from $R_1\ B_1$ , \dots, $R_m \ B_m$  where $C$}

With
\begin{description}
\item[$R_1 \ B_1 \dots R_m B_m$]  Tables or views and its renames, 

\item[$e_1 \dots e_n$] expressions involving constants, predefined functions and attributes,

\item[$C$] Boolean expression, including $\cod{false} \mid  \cod{true} \mid e_1 \diamond e_2 \mid  C_1\ \cod{ and }\ C_2 \mid  C_1\ \cod{ or }\ C_2 \mid  \cod{ not }\, C1 \mid \cod{exists(Q)}$  with $e_1, e_2$ arithmetic expressions,  $\diamond \in \{ =, <>, >, <, >=, <= \}$,  $C_1$, $C_2$ SQL conditions and $Q$ an SQL query.
\end{description}
\item [Unions] of the form $Q_1$ \cod{union} $Q_2$, with $Q_1$ and $Q_2$ queries.

\item [Intersections] of the form $Q_1$ \cod{intersects} $Q_2$, with $Q_1$ and $Q_2$ queries. 
\end{description}
\end{frame}

\begin{frame}{Introduction: Contributions}

\begin{itemize}
\item Generalize the treatment of \textbf{existential subqueries}, allowing nested subqueries.
\item Prove the proposal with respect to a simple SQL Operational Semantics.
\end{itemize}

\end{frame}

% \subsection{Approach}
% \begin{frame}[fragile]
%   \frametitle{Introduction: Approach}
%   \begin{itemize}
%   \item White-Box testing

%   \item Constraint programming over a symbolic database instance \\
%   \end{itemize}
  
% \begin{block}{Constraint Programming}
%     Uses conditions and relations over symbolic variables that constraint the possible values this variables can take.
%   \end{block}
%   \pause

%   \begin{block}{constraint}
%     First order logic formula which represents that relations and conditions over variables with an specific domain.
%   \end{block}
% \end{frame}
% \begin{frame}[fragile]{Approach}
%       %EJEMPLO
% \begin{verbatim}
% CREATE TABLE grades (ID int, grade int);
% \end{verbatim}

%   \begin{tabular}{|c|c|}
%     \hline
%     \textbf {ID} & \textbf {grade} \\
%     \hline
%     $ID_0$ & $grade_0$ \\
%     $ID_1$ & $grade_1$ \\
%     \hline
%   \end{tabular}
  
%   \begin{verbatim}
% CREATE VIEW excellent (ExcellentStudentID)
% AS SELECT ID FROM grades
% WHERE grade >= 9 and grade <=10;
% \end{verbatim}

%   \begin{block}{Constraint}  

% \begin{verbatim} 
% ((grades_grade_0 >= 9) /\ (grades_grade_0 <= 10)) 
% \/ ((grades_grade_1 >= 9) /\ (grades_grade_1 <= 10));
% \end{verbatim}
% \end{block}
  
% \end{frame}

%\subsection{Antecedentes}
%\begin{frame}
%\frametitle{Antecedentes}
%``Applying Constraint Logic Programming to SQL Test Case Generation'' por Rafael Caballero, Yolanda García-Ruiz y Fernando Sáenz-Pérez
%\begin{itemize}
%\item Caso de prueba SQL
%\item Programación con restricciones
%\end{itemize}
%\end{frame}
